package team.yidong.fenda.serviceImpl;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import team.yidong.fenda.entity.QuestionURL;
import team.yidong.fenda.repository.QuestionURLRepository;
import team.yidong.fenda.service.QuestionUrlService;

import java.util.List;

/**
 * Created by xuanlong on 2017/10/31.
 */
@Service
public class QuestionURLServiceImpl implements QuestionUrlService {
    @Autowired
    QuestionURLRepository questionURLRepository;

    @Override
    public JSONArray findQuestionUrl(Integer questionId) {
        JsonConfig config = new JsonConfig();
        config.setExcludes(new String[]{"question"});
        List<QuestionURL> questionURLList = questionURLRepository.findQuestionUrl(questionId);
        return JSONArray.fromObject(questionURLList,config);
    }
}
